<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>用户登录 在线答题系统</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
    <!-- head 中 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
</head>

<style>
    body, html {
        height: 100%;
        -webkit-tap-highlight-color: transparent;
    }

    .title{
        text-align: center;
        color: red;
        font-weight: 400;
        margin: 0 15%;
    }

    .sub-title {
        text-align: center;
        color: #888;
        font-size: 20px;
    }


    .header {
        padding:  0;
    }

    .titleImg{
       text-align: center;
    }

    #loginButton{
        margin-top: 45px;
        width: 55%;
    }

    .weui-footer {
        margin: 45px 0 10px 0;
    }

</style>


<body ontouchstart>
    <header class="header">
        <div class="titleImg">
           <img src="image/flag.png" width="225" height="118">
        </div>
        <h2 class="title">党的理论知识竞赛</h2>
        <h2 class="sub-title">在线答题系统</h2>
    </header>

    <div class="loginArea">
        <div class="weui-cells__title">请登录</div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">账号</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input"  placeholder="账号" id="userId">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password"   placeholder="密码" id="password">
                </div>
            </div>
        </div>

        <div class="weui-btn-area">
            <button class="weui-btn  weui-btn weui-btn_warn"  id="loginButton" onclick="login()" ontouchstart="login()">登   录</button>
        </div>

    </div>

    <div class="weui-footer">
        <p class="weui-footer__text">Copyright © 2019 北城移动应用开发工作室</p>
    </div>




</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>

<script>
    function login() {
        $.ajax({
            url:'user/login',
            method:'post',
            datatype:JSON,
            data:{
                userId:$("#userId").val(),
                password:$("#password").val()
            },
           success:function (data) {
               if (data.result===true) {
                   $.toast("登录成功");
                   if (data.type==="1")
                        window.location.href = "user/my";
                   else
                       window.location.href = "user/admin";
               }
               else
                   $.toast("账号或密码错误", "cancel");
           }

        })
    }
</script>



</html>